home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: MegaDisc
/
MegaDisc 27 (1992-03)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).zip
/
MegaDisc 27 (1992-03)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).adf
/
NumbersUp_Game
/
numbersup.PROGRAMMERS
< prev
next >
Wrap
Text File
|
1992-03-30
|
13KB
|
292 lines
********************
***
NUMBERS UP
***
********************
December, 1991.
THIS GAME IS BASED EXACTLY ON THE GAME NUMBERSUP BY RICHARD RAMELLA AND
ORIGINALLY PUBLISHED IN THE APRIL 1988 ISSUE OF JUMPDISK, THE ORIGINAL DISK
MAGAZINE FOR THE AMIGA. DECLARED WITHIN THE PUBLIC DOMAIN BY RICHARD RAMELLA
EFFECTIVE FEBRUARY 10, 1992.
###########################################################################
###########################################################################
###########################################################################
## ##
##
If you have any questions, comments, contributions, suggestions etc
##
##
PLEASE FORWARD THEM TO
##
## ##
##
Jason Lowe
##
##
5 Collaroy Close
##
##
Chittaway Bay
##
##
N.S.W 2259
##
##
Australia.
##
## ##
###########################################################################
###########################################################################
###########################################################################
************************************
***
INFORMATION TO PROGRAMMERS
***
************************************
Programmer:
Jason Lowe
Age:
18
Computer:
Amiga 500
Extras:
2 MB ram, 20 MB harddisk,
Laser Printer, External disk drive.
Completed:
December, 1991.
Comments:
- You can now use the space
bar aswell as the LMB!
- This is my first major program.
The idea was taken from Richard
Ramellas original game, "NUMBERSUP".
THIS PROGRAM USES ANDERS BJERINS INCLUDESOUND TO PLAY THE SOUND FOUND
IN THIS PROGRAM. THANKS ANDERS.
NumbersUp was written in Aztec C v5.0a by Jason Lowe. If there is only
the main source code with this game ( numbersup.c ) and none of the include
files and you would like to see the complete source code, just write. Or
if there is no source code at all with this program and you would like to
see it just write.
With this program I have written the whole game as many functions. I
then test each function as best I can and then when I am happy with a
particular function I will proceed to write more functions. With NumbersUp
I firstly got numbers running from both sides of the screen, then worked
out how to shoot them up, etc.
The functions I have used in NumbersUp are, (in no particular order)
- ViewInstructions
- ViewHighScores
- ClearSelected
- NumbersUp
- CheckHighScores
- InitHighScores
- LoadHighScores
- CreateBrandNew
- CreateNew
- InitRandom
- Up
- DisplayScore
- InitScreen
- InitLoc
- idcmpch
- Open_Stuff
- die
Now a small description of each of these functions,
- ViewInstructions
This draws a image into the rastport. It is drawn if the user presses
the letter "I" at the main menu.
- ViewHighScores
This will display the current top ten highscores. This is activated
if the user presses the right mouse button from the main menu. It is
also activated if the user gets a high score.
- ClearSelected
This clears the rectangular area where all the numbers are drawn. It
does no clear the main title "NumbersUp" and the surrounding border.
- NumbersUp
This is the main game NumbersUp. It is called when the user presses
the left mouse button from the main menu.
- CheckHighScores
This checks to see if the user has got a high. If the user has it
will change the high score list accordingly. It will also save the high
scores to disk if the user has previously specified.
- InitHighScores
This will try to load the high score table from disk. If it is
sucsessful the high scores used while the program is active will be those
loaded from the disk. If it can't open a high score table it will create a
brand new one consisting of all ten names being JASON and all having
scored 100 points.
- LoadHighScore
This loads all the high scores from disk into memory. It uses a
string array for the names loaded called names and for the scores it
uses an integer array called scores.
- CreateBrandNew
This creates a brand new high score table consisting of ten names
called JASON and ten scores of 100 points.
- CreateNew
This creates a new disk file of high scores if the user gets a high
score AND the user wishes to save thier scores to disk.
- InitRandom
This reseeds the random number generator.
- Up
This sends a number up from a specific location on the screen. It is
called from the function NumbersUp when the user presses the left mouse
button and a number is moving across the screen.
- DisplayScore
This displays the current score. It is called from NumbersUp when the
user has sent a number up, and thier score has changed.
- InitScreen
This draws the asterixes around the screen, so a border can specify
where the number can go.
- InitLoc
This clears all data about what numbers are where. It clears the
variable loc out such that the computer thinks there are no numbers on the
screen.
- idcmpch
This checks the IDCMP. It returns 1 for a left mouse button press, or
2 for a right mouse button press, or the raw value for any key pressed on
the key board.
- Open_Stuff
Opens the libraries needed, a screen, and a window.
- die
Frees everthing that needs freeing and also closes everything that
needs closing.
As I said above with this game, I test each fuction before proceeding to
write another. Heres the steps I used in writting Numbers Up.
1) Firstly get numbers flying in from both sides of the screen.
As you can see with this program, the numbers fly across very
smoothly IF you don't have many tasks in the background. I was originally
going to use sprites for the numbers which flew across the screen. But I
found another method which used very little memory and most importantly the
numbers flew across very smoothly.
As you know with sprites, when you move them around the screen the
hardware of the Amiga redraws what was under the sprite then redraws the
sprite where you want it to go. But what if you only want to move an object
around the screen and are not worried about redrawing the display under the
object. Obviously you wouldn't need sprites, but they COULD be used.
As you see in Numbers Up when a number flys in from one side of the
screen there is nothing under the number which needs to be redrawn. The
only function I used to scroll the numbers across the screen was Text(). If
you haven't used this function before, it simply writes a string to a
particular rastport.
When I have randomly picked the number which is to fly across the
screen, I simply create a string with only this number in it. BUT in the
string with the number I also write TWO spaces. One either side of the
number. For example, if I want to send the number six across, I would
create a string like this,
" 6 "
and I guess you can see why. If you move
the number only a few pixels to the left or to the right of where it
originally was it would completely wipe the old image out. This results in
quite smooth scrolling of the numbers. This may not sound all that
fantastic but it sure did save me from reserving sprites, and also reserving
the sprite data for each of the 9 numbers which need to fly across!
2) Once I had the numbers flying across the screen quite smoothly, I
then proceeded to write a function which moved a particular number up the
screen at a particular location.
The name of this function is "up()". If you look at the C source for
numbersup, you will see that I have declared a global variable ( accessable
by all functions) called "xpos". The function NumbersUp, changes the value
of xpos as the number moves across the screen. I move the number 4 pixels
each Screen Refresh, which means it moves quite smoothly and at a decent
playable speed.
But you may ask, how do you work out where the number gets shot up
seeing that the width of a number is 8 pixels! Actually I thought this may
be a downfall in the game, but it turned out to work quite well. If the
user decides to shoot a number up when it is halfway between where it
should go I simply move it another 4 pixels in the direction it is going
and then move it up the screen. Because the numbers are moving so fast, the
average user can not tell what is happening!
3) The next step was to check where the numbers should end up once they
where shot up.
I did this simply by creating an array, and storing each of the
numbers shot up at a particular location in the array. With this array, I
could simply add up the users score and also check to see if the user has
put two numbers together which are the same. This array is cleared at the
beginning of game and all the locations in the array are set to zero. This
way I can check to see if there is a number at a particular location simply
by testing if the array location dosen't equal zero!
Once I had the numbers running across smoothly, the score adding up
each game correctly and checking correctly if it was game over, it was time
to display the score, display when its game over etc.
The function DisplayScore(), simply writes the current score at the
top of the screen. It is called when the user sends a number up regardless
of whether they have scored addition points or not.
Then once the main idea behind Numbers Up was working ok I then
created a high Score table, added graphics and sound to liven things
up.
**** THE HIGH SCORE TABLE ****
There are two variables which hold the high score table. These are
'names' ( declared as a character array with 12 arrays each of 80
characters) and also 'scores' ( declared as an array of 12 of type
integer). The variable 'names' stores the names of the top ten people's
names. The variable 'scores' stores the top ten scores.
When the user has scored a high score, I simply change the these two
arrays and also save the scores to disk IF the user has previously
specified.
There are 6 functions used in the manipulation of the high scores.
They are all explained above.
**** THE GRAPHICS ****
The graphics of this program where designed with Deluxe Paint. They
are simple and make the program stand out. I converted the graphic images
to C source with PowerSource. PowerSource is an excellent program for
creating C source from graphic images as everything is done visually and
not through the CLI.
The game originally had no graphics and had a simple requestor which
asked you what you want to do. A freind then told me that I should make
the game more attractive, I did, and when you first load the game up it
looks interesting!
**** THE SOUND ****
The sound found in this program is taken from Public Domain Sources.
I originally loaded the sounds from disk, but now have found a new program
( Written by Anders Bjerin ) which enables you to include all sound effects
with the the main program. Very handy!
I suppose your wondering. Was it all that simple. Well the answer to
that was NO. My original version of numbers up was nothing compared to this
one. It jerked the numbers across the screen very slowly and it was
incredibly easy to score thousands of points. Plus the fact that each game
seem to take an eternity to play. I had to do something, and did.
Well thats the end of this doc file, I would like to go into more
depth about this game but it would be to time consuming to cover everything,
so if you've got any questions about what happens during this game, don't
hesistate to write. In the mean time...
*** HAPPY PROGRAMMING AND COMPUTING! ***
THE END